<template>
  <div class="chart" ref="myBar"></div>
</template>

<script>
import * as echarts from 'echarts'
import resize from '@/mixins/resize'
export default {
  name: 'BarChart',
  mixins: [resize],
  mounted() {
    // 注意必须要给chart给宽高
    // 初始化
    this.myEchart = echarts.init(this.$refs.myBar)
    this.myEchart.setOption({
      xAxis: {
        type: 'category',
        show: false,
        // 轴两边的距离
        boundaryGap: false
      },
      yAxis: {
        show: false
      },

      series: {
        type: 'bar',
        data: [15, 20, 35, 25, 19, 20, 30, 15],

        // 设置鼠标移上没有hover效果
        silent: true
        // 区域填充，线性渐变
      },
      grid: {
        top: 0,
        bottom: 0,
        left: 10,
        right: 10
      }
    })
  }
}
</script>

<style>
.chart {
  width: 100%;
  height: 100%;
}
</style>
